package JZOffer;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class _数组中出现次数超过一半的数字 {
    class Solution {
        public int MoreThanHalfNum_Solution(int [] array) {
            return 0;
        }

        private void PermutationHelper(char[] chars, int i, ArrayList<String> list) {
            if (i == chars.length-1) {
                list.add(String.valueOf(chars));
            }else {
                Set<Character> charSet = new HashSet<Character>();
                for (int j = i; j < chars.length; j++) {
                    if (j == i || !charSet.contains(chars[j])){
                        charSet.add(chars[j]);
                        swap(chars,i,j);
                        PermutationHelper(chars, i+1, list);
                        swap(chars,j,i);
                    }
                }
            }
        }

        private void swap(char[] cs, int i, int j) {
            char temp = cs[i];
            cs[i] = cs[j];
            cs[j] = temp;
        }
    }

    Solution getSolution() {
        return new Solution();
    }

    public static void main(String args[]) {
        _数组中出现次数超过一半的数字 c = new _数组中出现次数超过一半的数字();
        _数组中出现次数超过一半的数字.Solution s = c.getSolution();
        String str = "wwl";
//        ArrayList<String> res = s.Permutation(str);
//        for (String ele :
//                res) {
//            System.out.println(ele);
//        }
//        System.out.println(L1,7);
        
    }
}
